<template>
	<el-card shadow="never" header="消息提醒设置">
		<el-form ref="form" label-width="180px" label-position="left" style="margin-top:20px;">
			<el-form-item label="消息弹窗">
				<el-switch v-model="form.msgTip" inline-prompt active-value="1" inactive-value="0"></el-switch>
				<div class="el-form-item-msg">新消息自动弹出显示</div>
			</el-form-item>
			<el-form-item label="提示音效">
				<el-switch v-model="form.msgAudio" inline-prompt active-value="1" inactive-value="0" style="margin-right: 20px"></el-switch>
				<div class="el-form-item-msg">由于浏览器权限问题无法默认播放提示音，若想使用此功能，请您开启浏览器播放权限。如：chrome://settings/content/sound</div>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="updateUserInfo">保存</el-button>
			</el-form-item>
		</el-form>
	</el-card>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					msgTip: this.$TOOL.data.get('USER_INFO').msgTip,
					msgAudio: this.$TOOL.data.get('USER_INFO').msgAudio
				}
			}
		},
		mounted() {
		},
		methods:{
			async updateUserInfo(){
				var res = await this.$API.system.user.update.post(this.form);
				if (res.code == 200) {
					this.$alert("修改成功后，请重新登录！", "修改成功", {
						type: 'success',
						center: true
					}).then(() => {
						this.$router.replace({
							path: '/login'
						})
					}).catch(() => {})
				} else {
					this.$alert(res.message, "提示", {type: 'error'})
				}
			}
		}
	}
</script>

<style>
</style>
